home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #279 (1993)(Rhein-Sieg-Soft).zip / Franz PD Disk #279 (1993)(Rhein-Sieg-Soft).adf / ak_gen0-lib_V38.20.LHA / ak_gen0-library / Programmers.LHA / Programmers / Examples / OldReadDir.c < prev    next >
C/C++ Source or Header  |  1993-07-11  |  2KB  |  54 lines

  1.  
  2.  /* OldReadDir V38.1                                           */
  3.  /* FREEWARE.                                                  */
  4.  /* (c) 1993 by Andreas R. Kleinert.                           */
  5.  /* Demonstrates use of the "AK_ReadDir()" function.           */
  6.  /* This function is actually OBSOLETE and you should          */
  7.  /* use "AK_GetDirList()" instead, if possible.                */
  8.  /* Written in SAS/C V6.00 for OS V2.04 (V37) Includes.        */
  9.  
  10. #include <ak_gen0/ak_gen0_pragma.h>
  11.  
  12. #include <stdlib.h>
  13.  
  14. #include <proto/exec.h>
  15. #include <proto/intuition.h>
  16.  
  17. void main(long argc, char **argv) /* MAIN */
  18. {
  19.  printf("\nOldReadDir V38.1, FREEWARE, (c) 1993 by Andreas R. Kleinert.\n");
  20.  
  21.  AKBase = (struct AKBase *) OpenLibrary("ak_gen0.library", 37); /* minimum */
  22.  if(AKBase)
  23.   {
  24.    char *direntry[AK_MAX_READDIR_ENTRIES];
  25.    long dirtype [AK_MAX_READDIR_ENTRIES], count, i;
  26.  
  27.    for(i=0; i<AK_MAX_READDIR_ENTRIES; i++) direntry[i] = (APTR) AllocMem(AK_MAX_DOS_FILENAME_LEN, MEMF_CLEAR);
  28.  
  29.    if(direntry[i-1]) /* enough memory for all entries (test last one) ? */
  30.     {
  31.      if(argv[1]) count = AK_ReadDir(argv[1], &direntry[0], &dirtype[0]);
  32.       else       count = AK_ReadDir(     "", &direntry[0], &dirtype[0]);
  33.  
  34.      for(i=0; i<=count; i++)
  35.      {
  36.       printf("\n %ld : %s", i, direntry[i]);
  37.  
  38.       if(dirtype[i] == AKF_IS_DIR) printf(" (DIR)");
  39.       }
  40.  
  41.      printf("\n\n");
  42.     }
  43.  
  44.    for(i=0; i<AK_MAX_READDIR_ENTRIES; i++) if(direntry[i]) FreeMem(direntry[i], AK_MAX_DOS_FILENAME_LEN);
  45.  
  46.    CloseLibrary((APTR) AKBase);
  47.   }else
  48.   {
  49.    printf("\n Can't open \42ak_gen0.library\42 V37+ !\n");
  50.   }
  51.  
  52.  exit(0);
  53. }
  54.